import { GET_ACTIVE_MENU_BAR, SET_ACTIVE_MENU_BAR, ACTIVE_MENU_BAR_ACTION, STORAGE_ACTIVE_MENU_BAR } from '@/utils/Const';
import { Commit } from 'vuex';
import Storage from '@/utils/Storage';

interface State {
  value: string
}
export default {
  namespaced: true,
  state: {
    value: Storage.get(STORAGE_ACTIVE_MENU_BAR, 1) || '/dashboard'
  },
  getters: {
    [GET_ACTIVE_MENU_BAR](state: State) {
      return state.value
    }
  },
  mutations: {
    [SET_ACTIVE_MENU_BAR](state: State, payload): void {
      state.value = payload;
      Storage.set(STORAGE_ACTIVE_MENU_BAR, payload, 1);
    }
  },
  actions: {
    async [ACTIVE_MENU_BAR_ACTION](context: { commit: Commit }, paylod) {
      context.commit(SET_ACTIVE_MENU_BAR, paylod);
    }
  }
}